package com.yxzz.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.yxzz.core.domain.PDiagnosisRecord;
import com.yxzz.core.service.IPDiagnosisRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 中医诊断记录Controller
 *
 * @author ruoyi
 * @date 2023-02-28
 */
@RestController
@RequestMapping("/diagnosis")
public class PDiagnosisRecordController extends BaseController
{
    @Autowired
    private IPDiagnosisRecordService pDiagnosisRecordService;

    /**
     * 查询中医诊断记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PDiagnosisRecord pDiagnosisRecord)
    {
        startPage();
        List<PDiagnosisRecord> list = pDiagnosisRecordService.selectPDiagnosisRecordList(pDiagnosisRecord);
        return getDataTable(list);
    }


    /**
     * 获取中医诊断记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pDiagnosisRecordService.selectPDiagnosisRecordById(id));
    }

    /**
     * 新增中医诊断记录
     */
    @Log(title = "中医诊断记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PDiagnosisRecord pDiagnosisRecord)
    {
        return toAjax(pDiagnosisRecordService.insertPDiagnosisRecord(pDiagnosisRecord));
    }

    /**
     * 修改中医诊断记录
     */
    @Log(title = "中医诊断记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PDiagnosisRecord pDiagnosisRecord)
    {
        return toAjax(pDiagnosisRecordService.updatePDiagnosisRecord(pDiagnosisRecord));
    }

    /**
     * 删除中医诊断记录
     */
    @Log(title = "中医诊断记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pDiagnosisRecordService.deletePDiagnosisRecordByIds(ids));
    }
}
